<template>
	<view class="fs20">
		<view class="fixed w-max bg-fff bottom0 left0 flex row-around tc safe-area-inset-bottom"
			style="height: 50px; box-sizing: content-box;z-index: 998;">
			<view class="flex1" v-for="(item,index) in list" @click="$tool.sjump(item.pagePath)" :key="index">
				<block v-if="item.midButton">
					<image :src="item.selectedIconPath" class="w102 h50" mode="widthFix"></image>
				</block>
				<block v-else>
					<block v-if="current==index">
						<image :src="item.selectedIconPath" class="w48 h48" mode=""></image>
						<view class="color-zs">{{item.text}}</view>
					</block>
					<block v-else>
						<image :src="item.iconPath" class="w48 h48" mode=""></image>
						<view class="color-999">{{item.text}}</view>
					</block>
				</block>
			</view>
		</view>
		<view class="w-max safe-area-inset-bottom" style="height: 50px; box-sizing: content-box;"></view>
	</view>
</template>

<script>
	export default {
		name: "tabbar",
		props: {},
		created() {
			uni.hideTabBar();
			let pages = getCurrentPages()
			let page = pages[pages.length - 1]
			let path = decodeURI(page.route)
			this.current = this.list.findIndex(e => e.pagePath == '/' + path)
		},
		data() {
			return {
				current: '',
			};
		},
		computed: {
			list() {
				let aa = [{
						iconPath: "/static/img/tabbar/tabbar1.png",
						selectedIconPath: "/static/img/tabbar/tabbar10.png",
						text: '首页',
						pagePath: '/pages/index/index'
					},
					{
						iconPath: "/static/img/tabbar/tabbar2.png",
						selectedIconPath: "/static/img/tabbar/tabbar20.png",
						text: '订单',
						pagePath: '/pages/orderList/orderList'
					}
				]
				if (this.$config.is_quote != 0) {
					aa.push({
						iconPath: "/static/img/tabbar/add.png",
						selectedIconPath: "/static/img/tabbar/add.png",
						// text: '发布需求',
						midButton: true,
						pagePath: '/pages/release/release'
					})
				}
				aa.push({
					iconPath: "/static/img/tabbar/tabbar3.png",
					selectedIconPath: "/static/img/tabbar/tabbar30.png",
					text: '消息',
					pagePath: '/pages/news/news'
				}, {
					iconPath: "/static/img/tabbar/tabbar4.png",
					selectedIconPath: "/static/img/tabbar/tabbar40.png",
					text: '我的',
					pagePath: '/pages/my/my'
				})
				return aa
			}
		},

	}
</script>

<style lang="scss">
	// /deep/.u-tabbar__content__item__text {
	// 	font-size: 10px;
	// }
	.safe-area-inset-bottom {
		padding-bottom: 0;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}
</style>
